package chat.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.security.Provider.Service;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import chat.single.MsgSing;
import chat.user.UserBean;

public class ChatView extends HttpServlet {
	
	
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		String path = req.getContextPath();
		//获取数据	
		Object nameobj=	req.getSession().getAttribute("name");
		
		String name=nameobj==null?"":nameobj.toString();
	
		
		//输出数据
		PrintWriter w = resp.getWriter();
		w.println("<!DOCTYPE html>");
		w.println("<html>");
		w.println("<head>");
		w.println("<meta charset='UTF-8'>");
		w.println("<title></title>");
		w.println("<style type='text/css'>");
		w.println("#LoginMain{");
		w.println("width: 300px;");
		w.println("height: 400px;");
		w.println("background-color: lightblue ;");
		w.println("text-align: center;");
		w.println("margin: 0 auto;");
		w.println("border-radius:30px;");
		w.println("box-shadow:10px 10px 20px lightblue;");
		w.println("}");
		w.println("#Head{");
		w.println("width:100%;");
		w.println("height:15%;");
		w.println("background-color: whitesmoke;");
		w.println("border-radius:30px 30px 0px 0px;");
		w.println("}");
		w.println(".bt{");
		w.println("width: 80px;");
		w.println("background-color: #00CED1;");
		w.println("	color: white;");
		w.println("border: 1px;");
		w.println("border-radius: 5px;");
		w.println("background-color: #00CED1;");
		w.println("padding: 5px;");
		w.println("}");
		w.println("</style>");
		w.println("</head>");
		w.println("<body>");
		w.println("<div id='LoginMain' >");

		w.println("<div >");
		w.println("	聊天室");
		w.println("</div>");

		w.println("<div style='width:90%;height:75%;background-color: gray;text-align: center;margin: 0 auto;'>");
		w.println("<iframe name='iframe-1' src='"+path+"/ChatMsgView' width='99%' height='99%'></iframe>");
		w.println("</div>");
		
		
		w.println("<div style='position:relative;top:20px;' >");
		w.println("<form action='"+path+"/ChatViewAction' method='get'>");
		w.println(""+name+":");
		w.println("<input type='text' name='msg'/>");
		w.println("<a target='iframe-1' href='/ChatMsgView'><input class='bt' type='submit' value='发送'/></a>");
		w.println("</form>");
		w.println("</div>");
		w.println("</div>");
		w.println("</body>");
		w.println("</html>");
		w.flush();		
	}		
}
